package Design_patterns.creator_mode.singleton.demo10;

import java.io.IOException;
import java.io.InputStream;

/**
 * @description: 测试jdk中RunTime的单例模式
 **/

public class RuntimeDemo {
    public static void main(String[] args) throws IOException {

        //获取对象
        Runtime runtime = Runtime.getRuntime();
//        Runtime runtime2 = Runtime.getRuntime();
        //调用方法exec ,参数要的是一个命令
        Process process = runtime.exec("node -v");
        //调用 process 对象获取输入流的方法
        InputStream is = process.getInputStream();
        byte[] bytes = new byte[1024 * 1024 * 100];
        //读取数据 返回读到字节的个数
        int len = is.read(bytes);
        //将字节数组转换为字符串，输出到控制台
        //参数 字节数组 从字节数组第几位开始 读多少个长度
        System.out.println(new String(bytes,0,len,"GBK"));
        // v18.18.1

//        System.out.println(runtime==runtime2);
    }
}
